home *** CD-ROM | disk | FTP | other *** search
- // Listing 2 - Count2 program
-
- #include <cstring.h>
- #include <iomanip.h>
- #include <algo.h>
- #include <map.h>
-
- struct long_t { long v; long_t() : v(0) {} };
-
- typedef map< string, long_t, less<string> > map_t;
-
- static inline int show_m( const map_t::value_type& x )
- { cout << setw(7) << x.second.v << " - " << x.first << endl; }
-
- int main() {
-
- map_t ct_map;
- string str;
-
- while ( cin >> str ) ++ct_map[str].v;
-
- for_each( ct_map.begin(), ct_map.end(), ptr_fun( show_m ) );
-
- return EXIT_SUCCESS;
- }
-